var windowName = "site";
var Page,sites,files;
apiready = function(){
    sites = new List();
    files = new List();

    Page = createVM("#Page",{
        //页面数据
        list:[]
        ,tab:0
        ,text:""
        ,textFile:""
        ,files:[]
    },{
        //页面方法
        "init":function () {
            this.list = getLocData("cacheSites")
            this.files = getLocData("cacheFiles")
            // showLoading()
            sites.setUrl("/app/site/all")
                .setCbFunc(function (data) {
                    stopPullDownRefresh();
                    stopPullUpLoadMore();
                    // clearLoading();
                    // logJson(data,"站点数据：")
                    setLocData("cacheSites",data)
                    Page.list = data
                });
            files.setUrl("/app/file/all")
                .setCbFunc(function (data) {
                    stopPullDownRefresh();
                    stopPullUpLoadMore();
                    // clearLoading();
                    // logJson(data,"资料数据：")
                    setLocData("cacheFiles",data)
                    Page.files = data
                });
            // sites.getList();
        },
        OnPullDownRefresh: function () {
            startPullDownRefresh()
            if (this.tab === 0) {
                this.text=""
                sites.setData({text:""})
                sites.reload();
            }else {
                this.textFile=""
                files.setData({text:""})
                files.reload();
            }
        }
        ,OnPullUpLoadMore:function () {
            startPullUpLoadMore();
            if (this.tab === 0) {
                sites.getList();
            }else {
                files.getList();
            }
        }
        ,search: function () {
            log(this.text)
            sites.setData({text:this.text}).reload();
        }
        ,searchFile: function () {
            log(this.text)
            files.setData({text:this.textFile}).reload();
        }
    })

    Page.init()

}
function updateWinData() {
    log("site showed")
    setTimeout(function () {
        // showLoading();
        startPullDownRefresh()
        sites.reload();
        files.reload();
    },10)
}